package creditcard.gui;

import bank.BankFrm;
import framework.BaseManager;
import framework.account.IAccount;
import framework.command.ICommand;
import framework.command.impl.DepositCommand;

public class JDialog_Deposit extends javax.swing.JDialog {

	/**
	 * @uml.property name="parentframe"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	private View parentframe;
	/**
	 * @uml.property name="name"
	 */
	private String name;
	private IAccount account;

	public JDialog_Deposit(View parent, IAccount account) {
		super(parent);
		parentframe = parent;
        this.account = account;
		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		// {{INIT_CONTROLS
		setTitle("Deposit");
		setModal(true);
		getContentPane().setLayout(null);
		setSize(268, 126);
		setVisible(false);
		JLabel1.setText("Name");
		getContentPane().add(JLabel1);
		JLabel1.setForeground(java.awt.Color.black);
		JLabel1.setBounds(12, 12, 48, 24);
		JLabel2.setText("Amount");
		getContentPane().add(JLabel2);
		JLabel2.setForeground(java.awt.Color.black);
		JLabel2.setBounds(12, 48, 48, 24);
		JTextField_NAME.setEditable(false);
		getContentPane().add(JTextField_NAME);
		JTextField_NAME.setBounds(84, 12, 144, 24);
		JButton_OK.setText("OK");
		JButton_OK.setActionCommand("OK");
		getContentPane().add(JButton_OK);
		JButton_OK.setBounds(36, 84, 84, 24);
		JButton_Cancel.setText("Cancel");
		JButton_Cancel.setActionCommand("Cancel");
		getContentPane().add(JButton_Cancel);
		JButton_Cancel.setBounds(156, 84, 84, 24);
		getContentPane().add(JTextField_Deposit);
		JTextField_Deposit.setBounds(84, 48, 144, 24);
		// }}
		JTextField_NAME.setText(account.getAccountNo());

		// {{REGISTER_LISTENERS
		SymAction lSymAction = new SymAction();
		JButton_OK.addActionListener(lSymAction);
		JButton_Cancel.addActionListener(lSymAction);
		// }}
	}

	// {{DECLARE_CONTROLS
	/**
	 * @uml.property name="jLabel1"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	javax.swing.JLabel JLabel1 = new javax.swing.JLabel();
	/**
	 * @uml.property name="jLabel2"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	javax.swing.JLabel JLabel2 = new javax.swing.JLabel();
	/**
	 * @uml.property name="jTextField_NAME"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	javax.swing.JTextField JTextField_NAME = new javax.swing.JTextField();
	/**
	 * @uml.property name="jButton_OK"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	javax.swing.JButton JButton_OK = new javax.swing.JButton();
	/**
	 * @uml.property name="jButton_Cancel"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	javax.swing.JButton JButton_Cancel = new javax.swing.JButton();
	/**
	 * @uml.property name="jTextField_Deposit"
	 * @uml.associationEnd multiplicity="(1 1)"
	 */
	javax.swing.JTextField JTextField_Deposit = new javax.swing.JTextField();

	// }}

	class SymAction implements java.awt.event.ActionListener {
		public void actionPerformed(java.awt.event.ActionEvent event) {
			Object object = event.getSource();
			if (object == JButton_OK)
				JButtonOK_actionPerformed(event);
			else if (object == JButton_Cancel)
				JButtonCalcel_actionPerformed(event);
		}
	}

	void JButtonOK_actionPerformed(java.awt.event.ActionEvent event) {
        ICommand command = new DepositCommand(account, Float.valueOf(JTextField_Deposit.getText()));
        BaseManager.getInstance().execute(command);
        dispose();
	}

	void JButtonCalcel_actionPerformed(java.awt.event.ActionEvent event) {
		dispose();
	}
}